﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            SortedList sortList = new SortedList();
            sortList.Add(1, "张三");
            sortList.Add(3, "李四");
            sortList.Add(2, "王五");
            Console.WriteLine("请输入要查询的乘客座位号：");
            int id = int.Parse(Console.ReadLine());
            bool flag = sortList.ContainsKey(id);
            if (flag)
            {
                string name = sortList[id].ToString();
                Console.WriteLine($"您查找的乘客已上车姓名为：{name}");
            }
            else
            {
                Console.WriteLine("您查找的乘客还未上车！");
            }
            Console.WriteLine("所有乘客信息：");
            foreach(DictionaryEntry v in sortList)
            {
                Console.WriteLine($"座位号：{v.Key}\t姓名：{v.Value}");
            }
        }
    }
}
